# USB The **Quectel Pi M1/L1** smart main board comes with 2 standard **USB 3.0 Type-A** ports, 2 standard **USB 2.0 Type-A** ports, and 1 **USB 3.1 Type-C** port. The USB 2.0 ports support a maximum data transfer rate of 480 Mbps, and the USB 3.1 port supports a maximum data transfer rate of 5 Gbps. ```{image} images/image_Trmdb6Peoo2Sj4xHobUc3QRFnGb.webp :width: 883px :height: 583px :align: center ``` The **Quectel Pi M1/L1** onboard core has only one USB channel. It relies on an onboard hardware DIP switch to complete mode switching, enabling two core operating modes: USB Host and USB Device. This allows hardware switching to accommodate different scenarios such as device debugging and peripheral expansion. # USB Device Mode **DIP Switch Status:** Function DIP Switch 1 set to the ON position. **Operating Mode:** The board acts as a USB device, recognized, powered, and managed by a host computer (PC, debugging host). **Use Cases:** Firmware flashing, ADB debugging, data exchange with the host computer. **Features:** In this mode, the Type-C port only accepts commands from an external host and cannot connect to USB peripherals such as flash drives, keyboards, or mice. The device itself does not output USB power. This is the core mode for device debugging and mass production flashing. ```{image} images/image_NODfbw6mKoJ4jMxWnh3cLsCxnPh.webp :width: 794px :height: 523px :align: center ``` As shown above, switch DIP Switch 1 to the ON side. Connect one end of a USB cable to the Type-C port of the Quectel Pi and the other end to the PC. This completes the ADB connection. For PC-side ADB environment setup, refer to: ADB Terminal:[ADB Terminal](<../Device Connection/ADB Terminal/ADB Terminal.md>) ## ADB Usage - List All Connected Devices ```shell # Basic device list adb devices # Detailed device information list adb devices -l ``` - Check Device Status ```shell # device, offline, unknown adb get-state ``` - Reboot Device ```shell adb reboot ``` - Interactive Mode (Enter the Device Shell) ```shell adb shell ``` - Single Command Mode (Execute Without Entering Shell) ```shell adb shell df -h ``` - File Transfer ```shell # Upload a file adb push test.txt /data/ # Pull a file adb pull /data/test.txt ./ # Push a folder adb push ./MyPhotos /data/ # Pull a folder adb pull /data/MyPhotos ./ ``` # USB Host Mode **DIP Switch Status:** Toggle the corresponding function **DIP Switch 1** in the opposite direction. **Operating Mode:** The device acts as a **USB** host controller, actively managing the connected **USB** devices, supplying power to peripherals, and initiating data interaction. **Use Cases:** Connect peripherals such as USB flash drives, USB keyboards/mice, USB network adapters, sensors, etc., to enable data reading, human-machine interaction, and peripheral expansion. **Features:** In this mode, the Type-C port can actively recognize and drive connected USB devices, output USB power, and take on the host scheduling function, meeting the peripheral expansion needs of edge computing and industrial control scenarios. ```{image} images/image_DLeobhFBkoOIRCxAahrcIzWankg.webp :width: 589px :height: 387px :align: center ``` As shown above, switch **DIP Switch 1 to OFF** to complete the switch to Host mode. ## USB Storage Plug a USB flash drive into the **Quectel Pi** board, as shown below: ```{image} images/image_HtrUbcapNoanvZx69uxcebZon4e.webp :width: 1146px :height: 738px :align: center ``` ### Usage (GNOME) Log in to the Debian Gnome desktop and open the file manager. ```{image} images/image_H7VcbNk5SoBPCixTDorcwxRanne.webp :width: 1920px :height: 1080px :align: center ``` ### Usage (Weston) Use the `df -h` command via [Debug UART](<../Device Connection/Debug UART/Debug UART.md>) to check whether the USB flash drive is mounted successfully. ```{image} images/image_ZaK7bLrE1o7fpqxbX56cl19NnBc.webp :width: 636px :height: 118px ``` ## USB Camera ### View Camera Information Run the following command in the **SSH** terminal or the **Debug** terminal to view the **USB** camera information recognized by the system. ```shell dmesg | grep usb ``` ```{image} images/image_HyAGbso2EokkZWxNtEicDvbCnmf.webp :width: 1437px :height: 167px :align: center ``` ### **View Device Node Information** Run the following command in the **SSH** terminal or the **Debug** terminal to view the newly added device nodes. ```shell v4l2-ctl --list-devices # If it prompts "v4l2-ctl: command not found", run the following commands to install it after connecting to the network sudo apt update sudo apt install v4l-utils ``` ```{image} images/image_JHDhbvPNSoz4sHxU2JWcuFsfnVe.webp :width: 842px :height: 405px :align: center ``` ### **View Supported Formats** Run the following command in the **SSH** terminal or the **Debug** terminal to view the formats supported by the **video** device node: ```shell v4l2-ctl --list-formats-ext --device /dev/video2 ``` ### Take a Photo (GNOME) Taking the **Quectel Pi M1** as an example, log in via **SSH** and run the following command in the **SSH** terminal: ```shell gst-launch-1.0 -e v4l2src device=/dev/video2 num-buffers=1 \ ! 'image/jpeg,width=640,height=480,framerate=30/1' \ ! filesink location=/home/pi/photo.jpg ``` - location=/home/**pi**/photo.jpg:Replace **pi** with the username you use to log in to the Gnome desktop. ```{image} images/image_GLvZbmBnno0JitxCSQucZheLnQz.webp :width: 1280px :height: 800px :align: center ``` ### Record a Video (GNOME) Taking the **Quectel Pi M1** as an example, run the following command in the **SSH** terminal. The **SSH** login user must be consistent with the **Gnome** desktop user. ```shell # The SSH login user must be consistent with the desktop login user, otherwise $(id -u) will not match the desktop user and the preview cannot be opened export XDG_RUNTIME_DIR=/run/user/$(id -u) export WAYLAND_DISPLAY=wayland-0 export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus gst-launch-1.0 -e v4l2src device=/dev/video2 ! "image/jpeg,width=640,height=480,framerate=30/1"! jpegdec ! videoconvert ! waylandsink async=false ``` ```{image} images/image_RecNbXoysojE5xxNdx7cUGs4nEc.webp :width: 1624px :height: 227px :align: center ``` ### Take a Photo (Weston) Taking the **Quectel Pi L1** as an example, run the following command in the **Debug** terminal: ```shell gst-launch-1.0 -e v4l2src device=/dev/video2 num-buffers=1 \ ! 'image/jpeg,width=640,height=480,framerate=30/1' \ ! filesink location=/home/photo.jpg ``` ```{image} images/image_THcVbdeD8o2WBfxK3PzceuEenvL.webp :width: 898px :height: 508px :align: center ``` ### Record a Video (Weston) Taking the **Quectel Pi L1** as an example, run the following command in the **Debug** terminal: ```shell export XDG_RUNTIME_DIR=/run/user/root export WAYLAND_DISPLAY=wayland-1 export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/root/bus gst-launch-1.0 -e v4l2src device=/dev/video2 ! 'image/jpeg,width=640,height=480,framerate=30/1' ! jpegdec ! videoconvert ! waylandsink async=false ``` ```{image} images/image_SDxqbCh9coZ02dxoY9HcioEvnzb.webp :width: 1549px :height: 330px :align: center ```